import request from '@/utils/request'

// 查询请假列表
export function listLeave(query) {
  return request({
    url: '/workflow/leave/page',
    method: 'get',
    params: query
  })
}

// 查询请假详情
export function getLeave(id) {
  return request({
    url: '/workflow/leave/' + id,
    method: 'get'
  })
}

// 新增请假
export function addLeave(data) {
  return request({
    url: '/workflow/leave',
    method: 'post',
    data: data
  })
}

// 修改请假
export function updateLeave(data) {
  return request({
    url: '/workflow/leave',
    method: 'put',
    data: data
  })
}

// 提交请假
export function submitLeave(id) {
  return request({
    url: '/workflow/leave/submit/' + id,
    method: 'post'
  })
}

// 取消请假
export function cancelLeave(id) {
  return request({
    url: '/workflow/leave/cancel/' + id,
    method: 'post'
  })
}

// 上传附件
export function uploadLeaveAttachment(data) {
  return request({
    url: '/workflow/leave/upload',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

// 获取我的请假列表
export function getMyLeaves(query) {
  return request({
    url: '/workflow/leave/my',
    method: 'get',
    params: query
  })
} 